package com.bonc.ioc.controller;

import com.bonc.ioc.base.controller.BaseController;
import com.bonc.ioc.base.page.PageResult;
import com.bonc.ioc.common.util.AppReply;
import com.bonc.ioc.service.StandardDetailService;
import com.bonc.ioc.service.StandardService;
import com.bonc.ioc.vo.StandardVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0
 * @description:
 * @author: wangqinglin
 * @date: 2021/4/8 15:11
 * @change : 2021/4/8 15:11 by q8541q@163.com  for init
 */
@RestController
@RequestMapping("/standardFore")
@Slf4j
public class StandardForeController extends BaseController {

    @Autowired
    private StandardService standardService;
    @Autowired
    private StandardDetailService standardDetailService;

    /**
     * getStandardInfoByPage
     * 前台 分页查询 标准信息
     *
     * @param
     * @return com.bonc.ioc.common.util.AppReply
     * @author wangqinglin
     * @date 2021/4/8 15:13
     * @change 2021/4/8 15:13 by q8541q@163.com for init
     * @since 1.0.0
     */
    @GetMapping("/getStandardInfoByPage/{choosedSjbs}")
    public AppReply getStandardInfoByPage(@PathVariable String choosedSjbs) throws BindException {
        PageResult pageResult = standardService.selectStandardInfoShowByPage(getPageData(), choosedSjbs);
        return AppReply.success(pageResult);
    }

    @GetMapping("/getStandardInfo")
    public AppReply getStandardInfo(@RequestParam String id) {
        return AppReply.success(standardService.selectByPrimaryKey(Long.valueOf(id)));
    }


    @GetMapping("/getStandDetailInfoListByPage")
    public AppReply getStandDetailInfoListByPage() throws Exception {
        PageResult pageResult = standardDetailService.getStandDetailInfoListByPage(getPageData());
        return AppReply.success(pageResult);
    }

    @GetMapping("/getStandDetailInfoRank/{rank}")
    public AppReply queryStandRanking(@PathVariable int rank) {
        List<StandardVo> list = standardService.queryStandRanking(rank);
        return AppReply.success(list);
    }

}
